<?php
/**
 * 自动判断插件，加载插件的路由文件
 */


if (!is_dir($pluginsDir = \think\facade\App::getRootPath() . 'plugins')) {
    return;
}

$appName = app('http')->getName();
$routeFilename = $appName . ".php";

\Sc\Util\Tool::dir($pluginsDir)->each(function (\Sc\Util\Tool\Dir\EachFile $eachFile) use ($routeFilename){
    if (count($eachFile->relativelyDirs) === 3
        && array_reverse($eachFile->relativelyDirs)[0] === 'route'
    ) {
        include $eachFile->filepath;
    }
});